<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of registers_model
 *
 * @author chandu
 */
class registers_model {

    //put your code here

    private $name;

    public function __construct() {
        // parent::__construct();
    }

    public function add_registers($table) {
        if (isset($_POST['schoolname']) && isset($_POST['registername']) && isset($_POST['acyear'])) {

            $schoolname = $_POST['module'];
            $registername = $_POST['registername'];
            $delete = $_POST['acyear'];

            $this->query = "SELECT schoolname FROM $table WHERE schoolname = '$schoolname'";
            $check = mysql_query($this->query) or die("There is some problem at checking the module and permission is already available or not");
            $check_data = mysql_num_rows($check);

            if ($check_data == 0) {

                $this->query = "INSERT INTO $table(schoolname, registername, acyear)  VALUES ('$schoolname', $registername, '$acyear')";
                $insert = mysql_query($this->query) or die("There is an error in inserting the module and permissions data in to the db table");
                if ($insert) {
                    return "Success";
                } else {
                    return "Failed";
                }
            } else {

                return "Areadyexist";
            }
        }
    }

}
